﻿@model Ingenuity.Web.Models.Ship

@{
    ViewData["Title"] = "出货操作";
}

<h2>出货操作</h2>
<div class="row">
    <div class="col-md-4">
        <form id="ship" asp-action="ProductShip">
            <div asp-validation-summary="ModelOnly" class="text-danger"></div>
            <div class="form-group">
                <label>@Model.OrderName</label>
            </div>
            <input type="hidden" asp-for="OrderId" />
            <div class="form-group">
                <label asp-for="WorkName" class="control-label">出货人</label>
                <input asp-for="WorkName" class="form-control" />
                <span asp-validation-for="WorkName" class="text-danger"></span>
            </div>
            <div class="form-group">
                <label asp-for="OutWay" class="control-label">出货方式</label>
                <input asp-for="OutWay" class="form-control" />
                <span asp-validation-for="OutWay" class="text-danger"></span>
            </div>
            <div class="form-group">
                <label asp-for="Count" class="control-label">出货数量</label>
                <input asp-for="Count" class="form-control" />
                <span asp-validation-for="Count" class="text-danger"></span>
            </div>
            <div class="form-group">
                <input type="submit" value="创建" class="btn btn-default" />
            </div>
        </form>
    </div>
</div>

<div>
    <a asp-action="ShipOperation">返回列表</a>
</div>

@section scripts{
<script type="text/javascript">
        var returnUrl = "@Url.Action("ShipOperation")";
        $(function () {
            $("#ship").submit(function (event) {
                event.preventDefault();
                var form = $(this);
                $.ajax({
                    url: '@Url.Action("ProductShip")',
                    type: 'POST',
                    data: form.serialize(),
                    dataType: "json",
                    success: function (data) {
                        if (data.success) {
                            layer.alert(data.message, { icon: 6 }, function () { 
                                window.location.href = returnUrl;
                            });
                        }
                        else{
                            layer.alert(data.message, { icon: 5 });
                        }
                    }
                });
            });
        });
</script>
}
